﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SEVN.Web.Framework.Modules.News
{
    public partial class ListNews0101 : System.Web.UI.UserControl
    {
        WebFrameDataContext db = new WebFrameDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            string cateID = Request.QueryString["cid"];

            if (cateID == null)
            {
                cateID = "3";
            }
            var data = (from a in db.Newsletters
                        where a.CategoryID.ToString() == cateID || a.Category.CategoryParentID.GetValueOrDefault().ToString() == cateID
                        orderby a.PostDate descending
                        select new { a.NewsID, a.Title, a.SubTitle, Image = a.Image != null ? a.Image : "../../Images/Design/Normal.gif", a.PostDate, IsNew = DateTime.Compare(a.PostDate.Value.AddDays(14), DateTime.Now) > 0 ? true : false }).Take(10).ToList();

            rptListNews.DataSource = data;
            rptListNews.DataBind();
        }
    }
}